<?php
$mag = '开卡失败,身份信息有误或未开户';
$url = 'NewCard.php';
$AccountCode = $_POST['AccountCode'];
$CardPwd = $_POST['CardPwd'];
$CardNo = '6225';
for ($i=0;$i<9;$i++){
    $CardNo=$CardNo.rand(0,9);
}
include_once '../tools/DbTools.php';
DbTools::InitDb();
$sql = "select  AccountId from accountinfo where AccountCode='$AccountCode'";
$date = DbTools::select($sql);
    if(!empty($date)){
        $AccountId= $date[0]['AccountId'];
    $sql = "insert into bankcard(CardNo,AccountId,CardPwd,CardMoney,CardState,CardTime)values('$CardNo','$AccountId','$CardPwd',0,0,NOW())";
    $fd = DbTools::noSelect($sql);
    if ($fd['status']){
        $mag = '开卡成功'.$CardNo;
        $url = 'adminInfo.php';
    }

    }
DbTools::close();
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
</head>
<body>
<input type="hidden" id="newUrl" value="<?php echo $url;?>">
<input type="hidden" id="msg" value="<?php echo $mag;?>">
</body>
<script>
    onload = function () {
        var newUrl = document.getElementById('newUrl').value;
        var msg = document.getElementById('msg').value;
        alert(msg);
        location.href = newUrl;
    }
</script>

</html>
